package nhatquang.gs.model;

import nhatquang.gs.controler.FruitManager;

import org.andengine.entity.modifier.ScaleModifier;
import org.andengine.entity.modifier.SequenceEntityModifier;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

public class FruitSell extends Sprite{
	private long T1;
	private long T2;
	private int row;
	private int collumn;

	public FruitSell(float pX, float pY, float pWidth, float pHeight,
			ITextureRegion pTextureRegion,
			VertexBufferObjectManager vertexBufferObject,int row,int collumn) {
				super(pX, pY, pWidth, pHeight, pTextureRegion, vertexBufferObject);
				T1=T2=System.currentTimeMillis();
				this.row = row;
				this.collumn=collumn;
	}
	
	
	public int getRow() {
		return row;
	}


	public void setRow(int row) {
		this.row = row;
	}


	public int getCollumn() {
		return collumn;
	}


	public void setCollumn(int collumn) {
		this.collumn = collumn;
	}


	@Override
	protected void onManagedUpdate(float pSecondsElapsed) {
		T2 = System.currentTimeMillis();
		if (FruitManager.INSTANCE.scale[row][collumn] && ((T2 - T1) >= 1000)) {
			System.gc();
			this.registerEntityModifier(new SequenceEntityModifier(
					new ScaleModifier(0.5f, 1f, 1.3f), new ScaleModifier(0.5f,
							1.3f, 1f)));
			T1 = T2;
		}
		super.onManagedUpdate(pSecondsElapsed);
	}

}
